﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace TimeSheet.UI.Views
{
    /// <summary>
    /// Class to get all day labels (day name and day number)
    /// </summary>
    public class WeekDayLabelView 
    {
        /// <summary>
        /// Initializes a new instance of a WeekDayLabelView
        /// </summary>
        /// <param name="weekDate"></param>
        public WeekDayLabelView(DateTime weekDate)
        {
            this.WeekDate = weekDate;
        }

        /// <summary>
        /// Get the week date set in the constructor
        /// </summary>
        public DateTime WeekDate { get; private set; }

        /// <summary>
        /// Return the Monday Day Number
        /// </summary>
        public String Monday
        {
            get
            {
                DateTime day = GetMondayDate();
                return Convert.ToString(day.Day);
            }
        }

        /// <summary>
        /// Return the Monday Day Number
        /// </summary>
        public String MondayName
        {
            get
            {
                DateTime day = GetMondayDate();
                return day.DayOfWeek.ToString();
            }
        }

        /// <summary>
        /// Return the Tuesday Day Number
        /// </summary>
        public String Tuesday
        {
            get
            {
                DateTime day = GetMondayDate().AddDays(1);
                return Convert.ToString(day.Day);
            }
        }

        /// <summary>
        /// Return the Tuesday Day Number
        /// </summary>
        public String TuesdayName
        {
            get
            {
                DateTime day = GetMondayDate().AddDays(1);
                return day.DayOfWeek.ToString();
            }
        }

        /// <summary>
        /// Return the Wednesday Day Number
        /// </summary>
        public String Wednesday
        {
            get
            {
                DateTime day = GetMondayDate().AddDays(2);
                return Convert.ToString(day.Day);
            }
        }

        /// <summary>
        /// Return the Wednesday Day Number
        /// </summary>
        public String WednesdayName
        {
            get
            {
                DateTime day = GetMondayDate().AddDays(2);
                return day.DayOfWeek.ToString();
            }
        }

        /// <summary>
        /// Return the Thursday Day Number
        /// </summary>
        public String Thursday
        {
            get
            {
                DateTime day = GetMondayDate().AddDays(3);
                return Convert.ToString(day.Day);
            }
        }

        /// <summary>
        /// Return the Thursday Day Number
        /// </summary>
        public String ThursdayName
        {
            get
            {
                DateTime day = GetMondayDate().AddDays(3);
                return day.DayOfWeek.ToString();
            }
        }

        /// <summary>
        /// Return the Friday Day Number
        /// </summary>
        public String Friday
        {
            get
            {
                DateTime day = GetMondayDate().AddDays(4);
                return Convert.ToString(day.Day);
            }
        }

        /// <summary>
        /// Return the Friday Day Number
        /// </summary>
        public String FridayName
        {
            get
            {
                DateTime day = GetMondayDate().AddDays(4);
                return day.DayOfWeek.ToString();
            }
        }

        /// <summary>
        /// Return the Saturday Day Number
        /// </summary>
        public String Saturday
        {
            get
            {
                DateTime day = GetMondayDate().AddDays(5);
                return Convert.ToString(day.Day);
            }
        }

        /// <summary>
        /// Return the Saturday Day Number
        /// </summary>
        public String SaturdayName
        {
            get
            {
                DateTime day = GetMondayDate().AddDays(5);
                return day.DayOfWeek.ToString();
            }
        }

        /// <summary>
        /// Return the Sunday Day Number
        /// </summary>
        public String Sunday
        {
            get
            {
                DateTime day = GetMondayDate().AddDays(6);
                return Convert.ToString(day.Day);
            }
        }

        /// <summary>
        /// Return the Sunday Day Number
        /// </summary>
        public String SundayName
        {
            get
            {
                DateTime day = GetMondayDate().AddDays(6);
                return day.DayOfWeek.ToString();
            }
        }

        /// <summary>
        /// Get the monday date for WeekDate
        /// </summary>
        /// <returns></returns>
        private DateTime GetMondayDate()
        {
            switch (this.WeekDate.DayOfWeek)
            {
                case DayOfWeek.Monday:
                    return this.WeekDate;
                case DayOfWeek.Tuesday:
                    return this.WeekDate.AddDays(-1);
                case DayOfWeek.Wednesday:
                    return this.WeekDate.AddDays(-2);
                case DayOfWeek.Thursday:
                    return this.WeekDate.AddDays(-3);
                case DayOfWeek.Friday:
                    return this.WeekDate.AddDays(-4);
                case DayOfWeek.Saturday:
                    return this.WeekDate.AddDays(-5);
                case DayOfWeek.Sunday:
                    return this.WeekDate.AddDays(-6);
                default:
                    return this.WeekDate;
            }
        }
        
    }
}
